<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta charset="UTF-8" />
    <script type="text/javascript" src="jquery-1.8.2.min.js"></script>
  </head>

  <style>
    * {
      margin: 0px;
      padding: 0px;
    }

    html,
    body {
      height: 100%;
      width: 100%;
      overflow: hidden;
      background-color: Transparent;
    }
    #panel-content-container {
      height: 100%;
      width: 100%;
    }
  </style>
  <body>
    <div id="panel-content-container"></div>
    <script>
      function setHeaders(headers) {
        var headTag = document.getElementsByTagName("head")[0];
        for (var index in headers) {
          var header = headers[index];
          var tagname = header.tagname;

          if (tagname != "script") {
            var element = document.createElement(tagname);
            for (var propertyName in header.attrs) {
              element[propertyName] = header.attrs[propertyName];
            }
            headTag.appendChild(element);
          } else {
            debugger
            //动态下载js 插入到head
            $.ajax({
              url: header.attrs.src,
              type: "GET",
              cache: false,
              dataType: "Text",
              async: false,
              success: function(result) {
                var script = document.createElement("script");
                script.innerHTML = result;
                document.getElementsByTagName("head")[0].appendChild(script);
              }
            });
          }
        }
      }

      function setBody(body) {
        document.getElementById("panel-content-container").innerHTML = body;
      }

      function setOptionAnRun(options, script) {
        var thisOptions = options;
        var thisScript = script;
        debugger;
        (function(container, context) {
          context.initPanel =
            context.initPanel ||
            function() {
              console.warn("initPanel is null");
            };
          context.showPanels =
            context.showPanels ||
            function() {
              console.warn("showPanels is null");
            };
          context.hidePanels =
            context.hidePanels ||
            function() {
              console.warn("hidePanels is null");
            };
          debugger;
          context.getPanelOptions = function() {
            return thisOptions;
          };
          //执行 脚本
          eval(thisScript);
        })(
          document.getElementById("panel-content-container"),
          (window.parent || {}).contextObj || {}
        );
      }
    </script>
  </body>
</html>
